<?php

namespace backend\models;

use Yii;
use common\models\UserInfo;
use yii\helpers\ArrayHelper;
use yii\db\ActiveRecord;
use backend\models\Qr;
use backend\models\PayTrade;

class Brand extends \yii\db\ActiveRecord
{
	public $grPBrandHead;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'grp_brand';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {    	
        return [
        ];
    }
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => Yii::t('app','名称'),
            'factory_id' => Yii::t('app','厂家id'),
            'order' => Yii::t('app','排序（默认可不填，不填同品牌id一致）'),
            'head_grp' => Yii::t('app','类别'),
            'useing' => Yii::t('app','使用状态'),
            'memo' => Yii::t('app','简短说明'),
            'tax_rate' => Yii::t('app','税率'),
        	'grPBrandHead'=>Yii::t('app','分类'),
        ];
    }
    public function getBrandFactory()
    {
    	return $this->hasOne(Factory::className(),['id'=>'factory_id']);
    }
    
    public function getgrPBrandHead()
    {
    	return $this->hasOne(GrpBrandHead::className(),['id'=>'head_grp']);
    }
 
    public function CheckBrandByName($name){
    	$brand=Brand::find()->where(['=','name',$name])->exists();
    	if($brand){
    		return true;
    	}else{
    		return false;
    	}
    }
}
